package com.bootdemo;

import java.util.stream.LongStream;

public class SumCalculator {
    public static void main(String[] args) {
        long n = 100000000L;
        long sum = LongStream.rangeClosed(1, n)
                .parallel() // 将流转换为并行流
                .sum();

        System.out.println("从1加到" + n + "的和为" + sum);
    }
}
